/**
 * 
 */
package idv.takeshi.software.productline.bookstore.domain.model.deliveryservice;

import java.math.BigDecimal;
import java.util.Date;

import org.apache.commons.lang.Validate;

/**
 * A factory for deliveryService.
 * @author takeshi
 *
 */
public class DeliveryServiceFactory {
	
	/**
	 * New a instance for DeliveryService.
	 * @param name
	 * @param deliveryFee
	 * @param deliveryFeeOffThreshold
	 * @param postal
	 * @return
	 */
	public DeliveryService newInstance(String name, float deliveryFee, float deliveryFeeOffThreshold,
			boolean postal){
		Validate.notEmpty(name, "name shall always not be empty/null");
		DeliveryService deliveryService = new DeliveryService();
		Date dateTime = new Date();
		
		deliveryService.setName(name);
		deliveryService.setDeliveryFee(new BigDecimal("" + deliveryFee));
		deliveryService.setDeliveryFeeOffThreshold(new BigDecimal("" + deliveryFeeOffThreshold));
		deliveryService.setCreateTime(dateTime);
		deliveryService.setUpdateTime(dateTime);
		deliveryService.setPostal(postal);
		
		return deliveryService;
	}

}
